package com.yqd.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class CreateStream {
    public static void main(String[] args) {
        //方式1：通过 java.util.Collection.stream() 方法用集合创建流
        List<String> list = Arrays.asList("a", "b", "c");
        Stream<String> stream1 = list.stream();
        //方式2：使用java.util.Arrays.stream(T[] array)方法用数组创建流
        String[] arr = {"a", "b", "c"};
        Stream<String> stream2 = Arrays.stream(arr);
        //方式3：使用Stream的静态方法：of()、iterate()、generate()
        Stream<Integer> stream3 = Stream.of(1, 2, 3, 4);
        Stream<Integer> stream4 = Stream.iterate(0, x -> x + 3);
        Stream<Double> stream5 = Stream.generate(Math::random);
    }
}
